home *** CD-ROM | disk | FTP | other *** search
- #define LINT_ARGS 1
- #include <dos.h>
- #include <string.h>
- #include <memory.h>
- #include <stdio.h>
- #include <process.h>
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
-
- int i, j;
- char file_name[80];
- static int num_files = 0; /* number of files checked */
- char dta[128];
- static long total = 0; /* total size of all files */
- static long size = 0;
- static long tot_cl[] = {0, 0, 0, 0}; /* total clusters required */
- static long max_cl[] = {315, 354, 316, 355};
- static char over[]="**OVER**"; /* overflow message */
- static char noover[]=" "; /* no overflow */
- char far *fn_fp;
- char far *dta_fp;
- char *ovmsg[4];
- union REGS inregs;
- union REGS outregs;
- struct SREGS segregs;
-
- fn_fp = file_name;
- dta_fp = dta;
-
- if(argc > 1) {
- strcpy(file_name, argv[1]);
- if(!strchr(file_name, '.')) {
- if(file_name[strlen(file_name) - 1] != '\\')
- strcat(file_name, "\\*.*");
- else
- strcat(file_name, "*.*");
- }
- } else
- strcpy(file_name, "*.*");
-
- segread(&segregs); /* read current value of seg regs */
-
- inregs.h.ah = 0x1A; /* set current dta address */
- segregs.ds = FP_SEG(dta_fp);
- inregs.x.dx = FP_OFF(dta_fp);
- intdosx(&inregs, &outregs, &segregs);
-
- segregs.ds = FP_SEG(fn_fp);
- inregs.x.dx = FP_OFF(fn_fp);
- inregs.x.cx = 0;
- inregs.h.ah = 0x4E;
-
- intdosx(&inregs, &outregs, &segregs); /* search for first file */
-
- if(outregs.x.cflag == 0) { /* if file found */
- ++num_files;
- memcpy(&size, &dta[26], 4);
- for(i = 0, j = 1; i < 4; i++, j *= 2)
- tot_cl[i] += cluster(size, j);
- total += size;
-
- do { /* find rest of files */
- inregs.h.ah = 0x4F; /* find next file */
- intdos(&inregs, &outregs);
-
- if(outregs.x.cflag == 0) { /* if file found */
- ++num_files;
- memcpy(&size, &dta[26], 4);
- for(i = 0, j = 1; i < 4; i++, j *= 2)
- tot_cl[i] += cluster(size, j);
- total += size;
- }
- } while (outregs.x.cflag == 0);
- }
-
- printf("\n\nNOTE: FULL PATHNAMES AND/OR FILENAMES MAY BE USED");
- printf(" AS ARGUMENT ON PROGRAM LINE");
- printf("\n\n\tNumber of files = %d Total size = %ld bytes",
- num_files, total);
-
- printf("\n\n\n ");
- printf("TOTAL STORAGE REQUIRED IN BYTES FOR THE FOLLOWING DISKS");
- printf("\n\n 160K SS 180K SS 320K DS 360K DS ");
- printf("10 MEG 20+MEG");
- printf("\n floppy floppy floppy floppy ");
- printf("hard hard");
- printf("\n\n %8ld %8ld %8ld %8ld %8ld %8ld",
- tot_cl[0] * 512L, tot_cl[0] * 512L, tot_cl[1] * 1024L,
- tot_cl[1] * 1024L, tot_cl[3] * 4096L, tot_cl[2] * 2048L);
- for(i = 0; i < 2; i++)
- if(tot_cl[0] > max_cl[i])
- ovmsg[i] = over;
- else
- ovmsg[i] = noover;
- for(; i < 4; i++)
- if(tot_cl[1] > max_cl[i])
- ovmsg[i] = over;
- else
- ovmsg[i] = noover;
- printf("\n %s %s %s %s\n\n", ovmsg[0], ovmsg[1], ovmsg[2],
- ovmsg[3]);
-
- exit(0);
-
- }
-
- cluster(file_size, num_sec)
- long file_size;
- int num_sec;
- {
-
- int num_clust; /* number of clusters required */
-
- num_sec *= 512; /* number of bytes per cluster */
- num_clust = file_size / (long)num_sec;
- if(file_size > ((long)num_sec * (long)num_clust))
- ++num_clust;
-
- return(num_clust);
-
- }